<template>
  <view
    class="trade-index-main-tabs-container"
    :class="{ darkStyle: theme === 'dark' }"
  >
    <view class="main-tabs-wrap">
      <view
        class="main-tabs-item"
        v-for="(item, index) in list"
        :class="{ active: index == current, 'border-bottom': borderBottom }"
        :data-current="index"
        @click="onClick"
        :key="index"
      >
        <span
          class="main-tabs-label"
          :style="{
            fontSize:
              (current === index
                ? activeStyle.fontSize
                : inActiveStyle.fontSize) + 'rpx',
          }"
        >
          {{ item.name }}
        </span>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  props: {
    list: { type: Array, default: () => [] },
    current: { type: Number | String, default: 0 },
    borderBottom: { type: Boolean, default: false },
    activeStyle: {
      type: Object,
      default: () => Object.create({ fontSize: 28 }),
    },
    inActiveStyle: {
      type: Object,
      default: () => Object.create({ fontSize: 28 }),
    },
  },
  data() {
    return {};
  },
  methods: {
    onClick(e) {
      const current = e.currentTarget.dataset.current;
      this.$emit("onClick", current);
    },
  },
};
</script>

<style lang="less" scoped>
.trade-index-main-tabs-container {
  padding: 0 30rpx;
  background-color: var(--page-part-color);
  &.darkStyle {
    .main-tabs-wrap {
      // color: #c8c8c8;
      .main-tabs-item {
        background-color: #434446;
        &.active {
          .main-tabs-label {
          }
        }
      }
    }
  }
  .main-tabs-wrap {
    display: flex;
    justify-content: space-between;
    color: #4a4a4a;
    .main-tabs-item {
      flex-basis: 0;
      flex-grow: 1;
      padding-right: 30rpx;
      display: flex;
      justify-content: center;
      align-items: center;
      background-color: #F7F7F7;
      color: #868686;
      border-width: 0;
      box-sizing: border-box;
      &.active {
        border: 1px solid var(--border-color);
        background-color: var(--page-part-color);
        .main-tabs-label {
          color: #F5BD65;
          position: relative;
        }
        &.border-bottom {
          .main-tabs-label {
            &::after {
              content: " ";
              position: absolute;
              bottom: 0;
              left: 50%;
              transform: translateX(-50%);
              width: 100%;
              // width: 30rpx;
              height: 4rpx;
              border-radius: 4rpx;
              background-color: @brand-color;
            }
          }
        }
      }
      .main-tabs-label {
        height: 60rpx;
        line-height: 60rpx;
        display: inline-block;
      }
    }
  }
}
</style>
